#!/usr/bin/perl -w
####################################################
# Copyright (c) 2002-2007 BioWare Corp.
# http://www.bigdaddymonitor.org
#
# This file is part of the BigDaddy Monitoring
# program. It is free software distributed under
# the terms of the BSD License. It is ditributed
# in the hopes that it will be useful, but
# WITHOUT ANY WARRANTY; without event the implied
# warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
#
# The BSD License is available from:
# http://www.opensource.org/licenses/bsd-license.php
####################################################
#=============================================================================#
#BigDaddy Module: Windows SNMP Hard Disk Capacity Check
#Author: Duleepa Wijayawardhana
#Date: 30.01.2005
#=============================================================================#

=intro

=cut

use strict;
my ($sServer, $sPSCheck) = @ARGV;

my $bIsRunning = 0;

my @aResults=`snmpwalk -c public -v 1 $sServer HOST-RESOURCES-MIB::hrSWRunName`;

if (scalar(@aResults) < 2)
{
    exit;
}

foreach my $sLine (@aResults)
{
    if (!defined ($sLine))
    {
        exit;
    }
    
    if ($sLine =~ m/hrSWRunName.[0-9]+ = STRING: "(.*?)"/i)
    {
        if (lc($sPSCheck) eq lc($1))
        {
            $bIsRunning = 1;
        }
    }
}


print $bIsRunning;
